#ifndef SENDERWIDGET_H
#define SENDERWIDGET_H

#include <QWidget>
#include <QListWidgetItem>
#include <thread>
#include <unordered_map>
#include "worker.h"


namespace Ui {
class SenderWidget;
}

class SenderWidget : public QWidget
{
    Q_OBJECT

public:
    explicit SenderWidget(QWidget *parent, const QString& devicename);
    ~SenderWidget();
    void initState();
private slots:
    void on_btnShareStart_clicked(); //开始屏幕共享
    void on_btnShareStop_clicked(); //结束共享

    void on_listWidget_itemClicked(QListWidgetItem *item);

    void on_lineEdit_returnPressed();

private:
    void search(); //设备搜索
private:
    Ui::SenderWidget *ui;
    Worker *worker; //工作者线程
    QString name; //设备昵称
    std::unordered_map<QString, QString> devicesMap; //存放搜索到的设备[ip, name]
    QString destIP = "127.0.0.1"; //当前所选择的目标主机IP
    std::thread *deviceSearcher = nullptr; //设备搜索线程
};

#endif // SENDERWIDGET_H
